home *** CD-ROM | disk | FTP | other *** search
- Subject: v01i073: Patches for calentool (to patchlevel 4), Part02/04
- Newsgroups: comp.sources.sun
- Approved: mcgrew@aramis.rutgers.edu
-
- Submitted-by: Bill Randle <billr@saab.cna.tek.com>
- Posting-number: Volume 1, Issue 73
- Archive-name: calentool/patch4b
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 2 (of 4)."
- # Contents: patches04b
- # Wrapped by billr@saab on Tue Sep 19 06:29:57 1989
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'patches04b' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'patches04b'\"
- else
- echo shar: Extracting \"'patches04b'\" \(52733 characters\)
- sed "s/^X//" >'patches04b' <<'END_OF_FILE'
- X*** /tmp/,RCSt1a05555 Wed Jul 19 20:46:02 1989
- X--- moon.c Wed Jul 19 20:29:00 1989
- X***************
- X*** 1,5
- X /*
- X! * $Header: moon.c,v 2.1 89/05/09 14:19:22 billr Exp $
- X */
- X /*
- X * moon.c
- X
- X--- 1,5 -----
- X /*
- X! * $Header: moon.c,v 2.2 89/07/19 20:28:12 billr Exp $
- X */
- X /*
- X * moon.c
- X***************
- X*** 9,15
- X * Bill Randle, Tektronix, Inc. to interface to the calentool
- X * program.
- X */
- X! #include "ct.h" /* for the NO_SUN_MOON #define */
- X #ifndef NO_SUN_MOON
- X
- X /*
- X
- X--- 9,15 -----
- X * Bill Randle, Tektronix, Inc. to interface to the calentool
- X * program.
- X */
- X! #include "ct.h" /* for the NO_SUN_MOON #define */
- X #ifndef NO_SUN_MOON
- X
- X /*
- X***************
- X*** 16,22
- X
- X A Moon for the Sun
- X
- X! Release 2.0
- X
- X Designed and implemented by John Walker in December 1987,
- X revised and updated in February of 1988.
- X
- X--- 16,22 -----
- X
- X A Moon for the Sun
- X
- X! Release 2.3
- X
- X Designed and implemented by John Walker in December 1987,
- X revised and updated in February of 1988.
- X***************
- X*** 20,25
- X
- X Designed and implemented by John Walker in December 1987,
- X revised and updated in February of 1988.
- X
- X cc -O moontool.c -o moontool -lm -lsuntool -lsunwindow -lpixrect
- X
- X
- X--- 20,26 -----
- X
- X Designed and implemented by John Walker in December 1987,
- X revised and updated in February of 1988.
- X+ revised and updated again in June of 1988 by Ron Hitchens
- X
- X Make with:
- X
- X***************
- X*** 21,26
- X Designed and implemented by John Walker in December 1987,
- X revised and updated in February of 1988.
- X
- X cc -O moontool.c -o moontool -lm -lsuntool -lsunwindow -lpixrect
- X
- X Adding appropriate floating point options to your hardware. This
- X
- X--- 22,29 -----
- X revised and updated in February of 1988.
- X revised and updated again in June of 1988 by Ron Hitchens
- X
- X+ Make with:
- X+
- X cc -O moontool.c -o moontool -lm -lsuntool -lsunwindow -lpixrect
- X
- X Adding appropriate floating point options to your hardware. This
- X***************
- X*** 75,80
- X program. Please leave the original attribution information intact so
- X that credit and blame may be properly apportioned.
- X
- X */
- X
- X /* Astronomical constants */
- X
- X--- 78,147 -----
- X program. Please leave the original attribution information intact so
- X that credit and blame may be properly apportioned.
- X
- X+ Revision history:
- X+
- X+ 1.0 11/5/87 First version. Only displayed icon, no
- X+ open window information display.
- X+
- X+ 2.0 3/27/88 First posting to comp.sources.unix.
- X+
- X+ 2.1 6/16/88 Bug fix. Table of phases didn't update
- X+ at the moment of the new moon. Call on
- X+ phasehunt didn't convert civil Julian date
- X+ to astronomical Julian date. Reported by
- X+ Dag Bruck (dag@control.lth.se).
- X+
- X+ 2.2 2/27/89 Michael McClary (michael@xanadu.COM)
- X+ Added moon map, derived from the sun "fullmoon"
- X+ image file. (It has not been checked for
- X+ rotation from the correct orientation. Also, a
- X+ fixed icon doesn't model the librations of the
- X+ moon as viewed from the earth.) Also: tweaked
- X+ corners of icon.
- X+
- X+ 2.3 6/7/89 Bug fix. Table of phases skipped the phases
- X+ for July 1989. This occurred due to sloppy
- X+ maintenance of the synodic month index in the
- X+ interchange of information between phasehunt()
- X+ and meanphase(). I simplified and corrected
- X+ the handling of the month index as phasehunt()
- X+ steps along and removed unneeded code from
- X+ meanphase(). Reported by Bill Randle of
- X+ Tektronix, Inc. (billr@saab.CNA.TEK.COM).
- X+
- X+ Additional History:
- X+
- X+ June 1988 Modified by Ron Hitchens to produce version 2.1
- X+ modified icon generation to show surface texture
- X+ on visible moon face. Eliminated "illegal" direct
- X+ modification of icon image memory.
- X+ added a menu to allow switching in and out of
- X+ test mode, for entertainment value mostly.
- X+ reworked timer behaviour so that process doesn't
- X+ wake up unnecessarily.
- X+ trap sigwinch signals to notice more easily when the
- X+ tool opens and closes.
- X+ modified layout of information in open window display
- X+ to reduce the amount of pixels modified in each
- X+ update. Batched pixwin updates so that only one
- X+ screen rasterop per cycle is done.
- X+ changed open window to display white-on-black for a
- X+ more aesthetic look, and to suggest the effect of
- X+ looking at the moon in the nighttime sky.
- X+ setup default tool and canvas colors to be the same
- X+ as B&W monochrome, for those us lucky enough to have
- X+ color monitors and who have the default monochrome
- X+ colors set to something other than B&W (I like white
- X+ on dark blue myself)
- X+ various code reformatting and pretty-printing to suit
- X+ my own coding taste (I got a bit carried away).
- X+ code tweaking to make lint happy.
- X+ returned my hacked version to John.
- X+
- X+ Ron Hitchens
- X+ ronbo@vixen.uucp
- X+ ...!uunet!cs.utexas.edu!vixen!ronbo
- X+ hitchens@cs.utexas.edu
- X */
- X
- X
- X***************
- X*** 77,82
- X
- X */
- X
- X /* Astronomical constants */
- X
- X #define epoch 2444238.5 /* 1980 January 0.0 */
- X
- X--- 144,167 -----
- X hitchens@cs.utexas.edu
- X */
- X
- X+
- X+ #include <stdio.h>
- X+ #include <math.h>
- X+ #include <sys/time.h>
- X+
- X+ #include <suntool/sunview.h>
- X+ #include <suntool/canvas.h>
- X+
- X+ #define TINYFONT "/usr/lib/fonts/fixedwidthfonts/screen.r.7"
- X+
- X+ /*
- X+ * define standard B/W monochrome colors as defaults in case we're running
- X+ * on a color system with the monochrome colors set differently
- X+ */
- X+ #define FG_DEFAULT { 0, 0, 0 } /* black */
- X+ #define BG_DEFAULT { 255, 255, 255 } /* white */
- X+
- X+
- X /* Astronomical constants */
- X
- X #define epoch 2444238.5 /* 1980 January 0.0 */
- X***************
- X*** 80,86
- X /* Astronomical constants */
- X
- X #define epoch 2444238.5 /* 1980 January 0.0 */
- X! #define J1970 2440587.5 /* VAX clock Epoch 1970 Jan 1 (0h UT) */
- X
- X /* Constants defining the Sun's apparent orbit */
- X
- X
- X--- 165,171 -----
- X /* Astronomical constants */
- X
- X #define epoch 2444238.5 /* 1980 January 0.0 */
- X! #define J1970 2440587.5 /* VAX clock Epoch 1970 Jan 1 (0h UT) */
- X
- X /* Constants defining the Sun's apparent orbit */
- X
- X***************
- X*** 114,122
- X
- X #define earthrad 6378.16 /* Radius of Earth in kilometres */
- X
- X- #include <stdio.h>
- X- #include <math.h>
- X- #include <sys/time.h>
- X
- X #include <suntool/sunview.h>
- X #include <suntool/canvas.h>
- X
- X--- 199,204 -----
- X
- X #define earthrad 6378.16 /* Radius of Earth in kilometres */
- X
- X
- X #define PI 3.14159265358979323846 /* Assume not near black hole nor in
- X Tennessee */
- X***************
- X*** 118,174
- X #include <math.h>
- X #include <sys/time.h>
- X
- X- #include <suntool/sunview.h>
- X- #include <suntool/canvas.h>
- X-
- X- /* Icon definition. This is just a black field with rounded corners
- X- that blend into the root desktop pattern. The image of the moon and
- X- the text are added by the program later. */
- X-
- X- static short moon_img[64][4] = {
- X- /* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16 */
- X- 0x8FFF,0xFFFF,0xFFFF,0xFFE8,0x9FFF,0xFFFF,0xFFFF,0xFFF8,
- X- 0x3FFF,0xFFFF,0xFFFF,0xFFFE,0x7FFF,0xFFFF,0xFFFF,0xFFFE,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFE,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0x7FFF,0xFFFF,0xFFFF,0xFFFE,
- X- 0xFFFF,0xFFFF,0xFFFF,0xFFFE,0xBFFF,0xFFFF,0xFFFF,0xFFFC,
- X- 0x3FFF,0xFFFF,0xFFFF,0xFFFA,0x27FF,0xFFFF,0xFFFF,0xFFE2
- X- };
- X- DEFINE_ICON_FROM_IMAGE(moon_icon, moon_img);
- X- mpr_static(icon_mpr, 64, 64, 1, moon_img);
- X-
- X- extern Canvas mcanvas;
- X- extern Pixfont *font;
- X- extern char *monthnames[];
- X- static Pixwin *cpw;
- X- static int charhgt, charwid;
- X-
- X #define PI 3.14159265358979323846 /* Assume not near black hole nor in
- X Tennessee */
- X
- X
- X--- 200,205 -----
- X #define earthrad 6378.16 /* Radius of Earth in kilometres */
- X
- X
- X #define PI 3.14159265358979323846 /* Assume not near black hole nor in
- X Tennessee */
- X
- X***************
- X*** 182,188
- X #define dsin(x) (sin(torad((x)))) /* Sin from deg */
- X #define dcos(x) (cos(torad((x)))) /* Cos from deg */
- X
- X- /* Forward functions */
- X
- X double jtime(), phase();
- X void phasehunt();
- X
- X--- 213,218 -----
- X #define dsin(x) (sin(torad((x)))) /* Sin from deg */
- X #define dcos(x) (cos(torad((x)))) /* Cos from deg */
- X
- X
- X /*
- X * Moon image. This is a standard icon-sized picture of the moon's face.
- X***************
- X*** 184,192
- X
- X /* Forward functions */
- X
- X! double jtime(), phase();
- X! void phasehunt();
- X! void drawmoon(), jyear(), jhms();
- X
- X
- X /* DRAWMOON -- Construct icon for moon, given phase of moon. */
- X
- X--- 214,224 -----
- X #define dcos(x) (cos(torad((x)))) /* Cos from deg */
- X
- X
- X! /*
- X! * Moon image. This is a standard icon-sized picture of the moon's face.
- X! * The visible part, as calculated by the current time, is extracted from
- X! * this image to create the displayed image.
- X! */
- X
- X static short moon_img [] = {
- X #include "moon.icon"
- X***************
- X*** 188,193
- X void phasehunt();
- X void drawmoon(), jyear(), jhms();
- X
- X
- X /* DRAWMOON -- Construct icon for moon, given phase of moon. */
- X
- X
- X--- 220,229 -----
- X * this image to create the displayed image.
- X */
- X
- X+ static short moon_img [] = {
- X+ #include "moon.icon"
- X+ };
- X+ mpr_static(moon_mpr, 64, 64, 1, moon_img);
- X
- X extern Pixfont *font; /* pointer to regular icon font */
- X extern Pixfont *sfont; /* pointer to tiny icon font */
- X***************
- X*** 189,195
- X void drawmoon(), jyear(), jhms();
- X
- X
- X! /* DRAWMOON -- Construct icon for moon, given phase of moon. */
- X
- X static void drawmoon(ph)
- X double ph;
- X
- X--- 225,239 -----
- X };
- X mpr_static(moon_mpr, 64, 64, 1, moon_img);
- X
- X! extern Pixfont *font; /* pointer to regular icon font */
- X! extern Pixfont *sfont; /* pointer to tiny icon font */
- X! extern Canvas mcanvas; /* handle for the canvas */
- X! extern char *monthnames[];
- X! static Pixrect *icon_mpr; /* actual displayed pixrect */
- X! static Pixwin *cpw; /* pointer to the canvas' pixwin */
- X! static int charhgt, charwid; /* default std font height/width */
- X! static int info_col;
- X! static struct timezone tzp;
- X
- X static char *labels [] = {
- X "Moon phase:",
- X***************
- X*** 191,198
- X
- X /* DRAWMOON -- Construct icon for moon, given phase of moon. */
- X
- X! static void drawmoon(ph)
- X! double ph;
- X {
- X int i, j, lx, rx;
- X int lb[4];
- X
- X--- 235,265 -----
- X static int info_col;
- X static struct timezone tzp;
- X
- X! static char *labels [] = {
- X! "Moon phase:",
- X! "Age of moon:",
- X! "Moon's distance:",
- X! "Moon subtends:",
- X! "Last new moon:",
- X! "First quarter:",
- X! "Full moon:",
- X! "Last quarter:",
- X! "Next new moon:"
- X! };
- X!
- X! /* Forward functions */
- X! static double jtime(), phase();
- X! static void phasehunt(), set_mode();
- X! static void drawmoon(), jyear(), jhms();
- X!
- X!
- X! /*
- X! * DRAWMOON -- Construct icon for moon, given phase of moon.
- X! */
- X!
- X! static void drawmoon (ph, src_pr, dst_pr)
- X! double ph;
- X! Pixrect *src_pr, *dst_pr;
- X {
- X register int i, lx, rx;
- X register double cp, xscale;
- X***************
- X*** 194,202
- X static void drawmoon(ph)
- X double ph;
- X {
- X! int i, j, lx, rx;
- X! int lb[4];
- X! double cp, xscale;
- X
- X xscale = cos(2 * PI * ph);
- X for (i = 0; i < 24; i++) {
- X
- X--- 261,272 -----
- X double ph;
- X Pixrect *src_pr, *dst_pr;
- X {
- X! register int i, lx, rx;
- X! register double cp, xscale;
- X! #define RADIUS 27.0
- X! #define IRADIUS 27
- X! #define OFFSET 28
- X! #define CENTER 32
- X
- X /* Clear the destination pixrect to all one-bits (black) */
- X pr_rop (dst_pr, 0, 0, 64, 64, PIX_SET, (Pixrect *)0, 0, 0);
- X***************
- X*** 198,219
- X int lb[4];
- X double cp, xscale;
- X
- X! xscale = cos(2 * PI * ph);
- X! for (i = 0; i < 24; i++) {
- X! lb[0] = lb[1] = lb[2] = lb[3] = 0xFFFF;
- X! cp = 24.0 * cos(asin(i / 24.0));
- X! if (ph < 0.5) {
- X! rx = 32 + cp;
- X! lx = 32 + xscale * cp;
- X! } else {
- X! lx = 33 - cp;
- X! rx = 33 - xscale * cp;
- X! }
- X! for (j = lx; j <= rx; j++) {
- X! lb[j >> 4] &= (0x8000 >> (j & 0xF)) ^ 0xFFFF;
- X! }
- X! for (j = 0; j < 4; j++)
- X! moon_img[28 + i][j] = moon_img[28 - i][j] = lb[j];
- X }
- X }
- X
- X
- X--- 268,298 -----
- X #define OFFSET 28
- X #define CENTER 32
- X
- X! /* Clear the destination pixrect to all one-bits (black) */
- X! pr_rop (dst_pr, 0, 0, 64, 64, PIX_SET, (Pixrect *)0, 0, 0);
- X!
- X! xscale = cos (2 * PI * ph);
- X! for (i = 0; i < IRADIUS; i++) {
- X! cp = RADIUS * cos (asin (i / RADIUS));
- X! if (ph < 0.5) {
- X! rx = CENTER + cp;
- X! lx = CENTER + xscale * cp;
- X! } else {
- X! lx = CENTER - cp;
- X! rx = CENTER - xscale * cp;
- X! }
- X!
- X! /*
- X! * We now know the left and right endpoints of the scan line
- X! * for this y coordinate. We raster-op the corresponding
- X! * scanlines from the source pixrect to the destination
- X! * pixrect, offsetting to properly place it in the pixrect and
- X! * reflecting vertically.
- X! */
- X! pr_rop (dst_pr, lx, OFFSET + i, (rx - lx) + 1, 1, PIX_SRC,
- X! src_pr, lx, OFFSET + i);
- X! pr_rop (dst_pr, lx, OFFSET - i, (rx - lx) + 1, 1, PIX_SRC,
- X! src_pr, lx, OFFSET - i);
- X }
- X }
- X
- X***************
- X*** 217,222
- X }
- X }
- X
- X /* MOON_DATA -- print useful info about the moon */
- X
- X moon_data(seconds)
- X
- X--- 296,307 -----
- X }
- X }
- X
- X+ #define prt(y) pw_text(cpw, info_col, charhgt*(y), PIX_SRC, font, tbuf)
- X+ #define prtxy(x,y) pw_text(cpw, charwid*(y+1), charhgt*(x), PIX_SRC,\
- X+ font,tbuf)
- X+ #define EPL(x) (x), (x) == 1 ? "" : "s"
- X+ #define APOS(x) (x + 11)
- X+
- X /* MOON_DATA -- print useful info about the moon */
- X
- X moon_data(seconds)
- X***************
- X*** 222,238
- X moon_data(seconds)
- X long seconds;
- X {
- X! int lunation, wclosed;
- X! long t;
- X! double jd, p, aom, cphase, cdist, cangdia, csund, csuang, lptime;
- X! double phasar[5];
- X! struct pr_prpos tloc;
- X! char amsg[12], tbuf[80];
- X! static double faketime = 0.0;
- X! static short moonilast[64][4] = {0};
- X! int yy, mm, dd, hh, mmm, ss;
- X! Pixfont *pfont;
- X! struct tm *gm, *ltm, *localtime();
- X struct timeval tvp;
- X struct timezone tzp;
- X long clock;
- X
- X--- 307,320 -----
- X moon_data(seconds)
- X long seconds;
- X {
- X! int lunation, wclosed;
- X! int i, yy, mm, dd, hh, mmm, ss;
- X! int aom_d, aom_h, aom_m;
- X! long t;
- X! double jd, p, aom, cphase, cdist, cangdia, csund, csuang;
- X! double phasar [5];
- X! char tbuf[80];
- X! struct tm *gm, *ltm, *localtime();
- X struct timeval tvp;
- X struct pr_prpos tloc;
- X struct pr_size txt_size;
- X***************
- X*** 234,240
- X Pixfont *pfont;
- X struct tm *gm, *ltm, *localtime();
- X struct timeval tvp;
- X! struct timezone tzp;
- X long clock;
- X char *atp, *asctime();
- X
- X
- X--- 316,323 -----
- X char tbuf[80];
- X struct tm *gm, *ltm, *localtime();
- X struct timeval tvp;
- X! struct pr_prpos tloc;
- X! struct pr_size txt_size;
- X long clock;
- X char *atp, *asctime();
- X
- X***************
- X*** 238,245
- X long clock;
- X char *atp, *asctime();
- X
- X!
- X! pfont = pf_open("/usr/lib/fonts/fixedwidthfonts/screen.r.7");
- X cpw = canvas_pixwin(mcanvas);
- X charwid = font->pf_defaultsize.x;
- X charhgt = font->pf_defaultsize.y;
- X
- X--- 321,328 -----
- X long clock;
- X char *atp, *asctime();
- X
- X! icon_mpr = mem_create (64, 64, 1);
- X! pr_rop (icon_mpr, 0, 0, 64, 64, PIX_SRC, &moon_mpr, 0, 0);
- X cpw = canvas_pixwin(mcanvas);
- X charwid = font->pf_defaultsize.x;
- X charhgt = font->pf_defaultsize.y;
- X***************
- X*** 243,249
- X cpw = canvas_pixwin(mcanvas);
- X charwid = font->pf_defaultsize.x;
- X charhgt = font->pf_defaultsize.y;
- X! jd = jtime((gm = gmtime(&seconds)));
- X gettimeofday(&tvp, &tzp); /* for timezone info */
- X p = phase(jd, &cphase, &aom, &cdist, &cangdia, &csund, &csuang);
- X drawmoon(p);
- X
- X--- 326,333 -----
- X cpw = canvas_pixwin(mcanvas);
- X charwid = font->pf_defaultsize.x;
- X charhgt = font->pf_defaultsize.y;
- X! info_col = charwid * 20;
- X! jd = jtime ((gm = gmtime (&seconds)));
- X gettimeofday(&tvp, &tzp); /* for timezone info */
- X p = phase (jd, &cphase, &aom, &cdist, &cangdia, &csund, &csuang);
- X aom_d = (int) aom;
- X***************
- X*** 245,258
- X charhgt = font->pf_defaultsize.y;
- X jd = jtime((gm = gmtime(&seconds)));
- X gettimeofday(&tvp, &tzp); /* for timezone info */
- X! p = phase(jd, &cphase, &aom, &cdist, &cangdia, &csund, &csuang);
- X! drawmoon(p);
- X! sprintf(amsg, " %dd %dh ",
- X! (int) aom, ((int) (24 * (aom - floor(aom)))));
- X! tloc.pr = (Pixrect *) icon_get(&moon_icon, ICON_IMAGE);
- X! tloc.pos.x = 2;
- X! tloc.pos.y = 62;
- X! pf_text(tloc, PIX_NOT(PIX_SRC), pfont, amsg);
- X
- X /* Only update icon if it changed (this eliminates gratuitous
- X flashing of the icon on-screen). */
- X
- X--- 329,338 -----
- X info_col = charwid * 20;
- X jd = jtime ((gm = gmtime (&seconds)));
- X gettimeofday(&tvp, &tzp); /* for timezone info */
- X! p = phase (jd, &cphase, &aom, &cdist, &cangdia, &csund, &csuang);
- X! aom_d = (int) aom;
- X! aom_h = (int) (24 * (aom - floor(aom)));
- X! aom_m = (int) (1440 * (aom - floor(aom))) % 60;
- X
- X drawmoon(p, &moon_mpr, icon_mpr);
- X
- X***************
- X*** 254,261
- X tloc.pos.y = 62;
- X pf_text(tloc, PIX_NOT(PIX_SRC), pfont, amsg);
- X
- X! /* Only update icon if it changed (this eliminates gratuitous
- X! flashing of the icon on-screen). */
- X
- X if (bcmp(moonilast, moon_img, sizeof moon_img) != 0)
- X bcopy(moon_img, moonilast, sizeof moon_img);
- X
- X--- 334,340 -----
- X aom_h = (int) (24 * (aom - floor(aom)));
- X aom_m = (int) (1440 * (aom - floor(aom))) % 60;
- X
- X! drawmoon(p, &moon_mpr, icon_mpr);
- X
- X if (aom_d == 0) {
- X (void)sprintf(tbuf, "%dh %dm", aom_h, aom_m);
- X***************
- X*** 257,264
- X /* Only update icon if it changed (this eliminates gratuitous
- X flashing of the icon on-screen). */
- X
- X! if (bcmp(moonilast, moon_img, sizeof moon_img) != 0)
- X! bcopy(moon_img, moonilast, sizeof moon_img);
- X
- X /* Update textual information for open window */
- X
- X
- X--- 336,351 -----
- X
- X drawmoon(p, &moon_mpr, icon_mpr);
- X
- X! if (aom_d == 0) {
- X! (void)sprintf(tbuf, "%dh %dm", aom_h, aom_m);
- X! } else {
- X! (void)sprintf(tbuf, "%dd %dh", aom_d, aom_h);
- X! }
- X! txt_size = pf_textwidth (strlen (tbuf), sfont, tbuf);
- X! tloc.pos.x = (64 - txt_size.x) / 2;
- X! tloc.pos.y = 63;
- X! tloc.pr = icon_mpr;
- X! pf_text (tloc, PIX_NOT(PIX_SRC), sfont, tbuf);
- X
- X /* Update textual information for open window */
- X
- X***************
- X*** 262,269
- X
- X /* Update textual information for open window */
- X
- X! #define prt(x) pw_text(cpw, charwid, charhgt * (x), PIX_SRC, font, tbuf)
- X! #define prtxy(x,y) pw_text(cpw,charwid*(y+1),charhgt*(x),PIX_SRC,font,tbuf)
- X
- X sprintf(tbuf, "Moon phase: %d%% [0%% = New, 100%% = Full] ",
- X (int) (cphase * 100));
- X
- X--- 349,356 -----
- X
- X /* Update textual information for open window */
- X
- X! /* start batching updates to the pixwin */
- X! pw_batch_on (cpw);
- X
- X paint_labels();
- X /* moon phase */
- X***************
- X*** 265,272
- X #define prt(x) pw_text(cpw, charwid, charhgt * (x), PIX_SRC, font, tbuf)
- X #define prtxy(x,y) pw_text(cpw,charwid*(y+1),charhgt*(x),PIX_SRC,font,tbuf)
- X
- X! sprintf(tbuf, "Moon phase: %d%% [0%% = New, 100%% = Full] ",
- X! (int) (cphase * 100));
- X prt(1);
- X
- X /* Information about the Moon */
- X
- X--- 352,361 -----
- X /* start batching updates to the pixwin */
- X pw_batch_on (cpw);
- X
- X! paint_labels();
- X! /* moon phase */
- X! (void)sprintf (tbuf, "%d%% [0%% = New, 100%% = Full] ",
- X! (int) (cphase * 100));
- X prt(1);
- X
- X /* Information about the Moon */
- X***************
- X*** 271,281
- X
- X /* Information about the Moon */
- X
- X! #define EPL(x) (x), (x) == 1 ? "" : "s"
- X! sprintf(tbuf,
- X! "Age of moon: %d day%s, %d hour%s, %d minute%s. ",
- X! EPL((int) aom), EPL(((int) (24 * (aom - floor(aom))))),
- X! EPL(((int) (1440 * (aom - floor(aom)))) % 60));
- X prt(2);
- X sprintf(tbuf,
- X "Moon's distance: %ld kilometres, %.1f Earth radii. ",
- X
- X--- 360,368 -----
- X
- X /* Information about the Moon */
- X
- X! /* age of moon */
- X! (void)sprintf (tbuf, "%d day%s, %d hour%s, %d minute%s. ",
- X! EPL(aom_d), EPL(aom_h), EPL(aom_m));
- X prt(2);
- X
- X /* moon distance */
- X***************
- X*** 277,285
- X EPL((int) aom), EPL(((int) (24 * (aom - floor(aom))))),
- X EPL(((int) (1440 * (aom - floor(aom)))) % 60));
- X prt(2);
- X! sprintf(tbuf,
- X! "Moon's distance: %ld kilometres, %.1f Earth radii. ",
- X! (long) cdist, cdist / earthrad);
- X prt(3);
- X sprintf(tbuf,
- X "Moon subtends: %.4f degrees. ", cangdia);
- X
- X--- 364,373 -----
- X (void)sprintf (tbuf, "%d day%s, %d hour%s, %d minute%s. ",
- X EPL(aom_d), EPL(aom_h), EPL(aom_m));
- X prt(2);
- X!
- X! /* moon distance */
- X! (void)sprintf (tbuf, "%ld kilometres, %.1f Earth radii. ",
- X! (long) cdist, cdist / earthrad);
- X prt(3);
- X
- X /* moon subtends */
- X***************
- X*** 281,288
- X "Moon's distance: %ld kilometres, %.1f Earth radii. ",
- X (long) cdist, cdist / earthrad);
- X prt(3);
- X! sprintf(tbuf,
- X! "Moon subtends: %.4f degrees. ", cangdia);
- X prt(4);
- X /* Draw the moon icon in the text window */
- X pw_rop(cpw, 60 * charwid, charhgt, 64, 64, PIX_SRC,
- X
- X--- 369,377 -----
- X (void)sprintf (tbuf, "%ld kilometres, %.1f Earth radii. ",
- X (long) cdist, cdist / earthrad);
- X prt(3);
- X!
- X! /* moon subtends */
- X! (void)sprintf (tbuf, "%.4f degrees. ", cangdia);
- X prt(4);
- X
- X /* paint the moon's image in the upper right of the canvas */
- X***************
- X*** 284,292
- X sprintf(tbuf,
- X "Moon subtends: %.4f degrees. ", cangdia);
- X prt(4);
- X- /* Draw the moon icon in the text window */
- X- pw_rop(cpw, 60 * charwid, charhgt, 64, 64, PIX_SRC,
- X- &icon_mpr, 0, 0);
- X
- X
- X /* Calculate times of phases of this lunation. */
- X
- X--- 373,378 -----
- X /* moon subtends */
- X (void)sprintf (tbuf, "%.4f degrees. ", cangdia);
- X prt(4);
- X
- X /* paint the moon's image in the upper right of the canvas */
- X pw_rop (cpw, 60 * charwid, charhgt, 64, 64, PIX_SRC, icon_mpr, 0, 0);
- X***************
- X*** 288,293
- X pw_rop(cpw, 60 * charwid, charhgt, 64, 64, PIX_SRC,
- X &icon_mpr, 0, 0);
- X
- X
- X /* Calculate times of phases of this lunation. */
- X
- X
- X--- 374,381 -----
- X (void)sprintf (tbuf, "%.4f degrees. ", cangdia);
- X prt(4);
- X
- X+ /* paint the moon's image in the upper right of the canvas */
- X+ pw_rop (cpw, 60 * charwid, charhgt, 64, 64, PIX_SRC, icon_mpr, 0, 0);
- X
- X /*
- X * Calculate times of phases of this lunation.
- X***************
- X*** 289,295
- X &icon_mpr, 0, 0);
- X
- X
- X! /* Calculate times of phases of this lunation. */
- X
- X #define APOS(x) (x + 11)
- X phasehunt(jd, phasar);
- X
- X--- 377,386 -----
- X /* paint the moon's image in the upper right of the canvas */
- X pw_rop (cpw, 60 * charwid, charhgt, 64, 64, PIX_SRC, icon_mpr, 0, 0);
- X
- X! /*
- X! * Calculate times of phases of this lunation.
- X! */
- X! phasehunt(jd + 0.5, phasar);
- X
- X for (i = 0; i < 5; i++) {
- X fmt_phase_time (phasar[i], tbuf);
- X***************
- X*** 291,310
- X
- X /* Calculate times of phases of this lunation. */
- X
- X! #define APOS(x) (x + 11)
- X! phasehunt(jd, phasar);
- X! lptime = phasar[0];
- X! lunation = floor(((lptime + 7) - lunatbase) / synmonth) + 1;
- X! /* convert to seconds local time, so we can use localtime()
- X! to handle dst calculations */
- X! clock = (long)((lptime - J1970) * 24. * 3600.);
- X! ltm = localtime(&clock);
- X! sprintf(tbuf,
- X! "Last new moon: %02d:%02d %s %2d %s %d ",
- X! ltm->tm_hour, ltm->tm_min, timezone(tzp.tz_minuteswest, ltm->tm_isdst), ltm->tm_mday, monthnames[ltm->tm_mon], ltm->tm_year+1900);
- X! prt(APOS(0));
- X! sprintf(tbuf, "Lunation %d ", lunation);
- X! prtxy(APOS(0), 52);
- X
- X lptime = phasar[1];
- X /* convert to seconds local time, so we can use localtime()
- X
- X--- 382,391 -----
- X */
- X phasehunt(jd + 0.5, phasar);
- X
- X! for (i = 0; i < 5; i++) {
- X! fmt_phase_time (phasar[i], tbuf);
- X! prt(APOS(i));
- X! }
- X
- X lunation = floor(((phasar[0] + 7) - lunatbase) / synmonth) + 1;
- X (void)sprintf(tbuf, "Lunation %d ", lunation);
- X***************
- X*** 306,320
- X sprintf(tbuf, "Lunation %d ", lunation);
- X prtxy(APOS(0), 52);
- X
- X! lptime = phasar[1];
- X! /* convert to seconds local time, so we can use localtime()
- X! to handle dst calculations */
- X! clock = (long)((lptime - J1970) * 24. * 3600.);
- X! ltm = localtime(&clock);
- X! sprintf(tbuf,
- X! "First quarter: %02d:%02d %s %2d %s %d ",
- X! ltm->tm_hour, ltm->tm_min, timezone(tzp.tz_minuteswest, ltm->tm_isdst), ltm->tm_mday, monthnames[ltm->tm_mon], ltm->tm_year+1900);
- X! prt(APOS(1));
- X
- X lptime = phasar[2];
- X /* convert to seconds local time, so we can use localtime()
- X
- X--- 387,397 -----
- X prt(APOS(i));
- X }
- X
- X! lunation = floor(((phasar[0] + 7) - lunatbase) / synmonth) + 1;
- X! (void)sprintf(tbuf, "Lunation %d ", lunation);
- X! prtxy(APOS(0), 49);
- X! (void)sprintf(tbuf, "Lunation %d ", lunation + 1);
- X! prtxy(APOS(4), 49);
- X
- X /* flush the pixwin updates to the screen */
- X pw_batch_off (cpw);
- X***************
- X*** 316,330
- X ltm->tm_hour, ltm->tm_min, timezone(tzp.tz_minuteswest, ltm->tm_isdst), ltm->tm_mday, monthnames[ltm->tm_mon], ltm->tm_year+1900);
- X prt(APOS(1));
- X
- X! lptime = phasar[2];
- X! /* convert to seconds local time, so we can use localtime()
- X! to handle dst calculations */
- X! clock = (long)((lptime - J1970) * 24. * 3600.);
- X! ltm = localtime(&clock);
- X! sprintf(tbuf,
- X! "Full moon: %02d:%02d %s %2d %s %d ",
- X! ltm->tm_hour, ltm->tm_min, timezone(tzp.tz_minuteswest, ltm->tm_isdst), ltm->tm_mday, monthnames[ltm->tm_mon], ltm->tm_year+1900);
- X! prt(APOS(2));
- X
- X lptime = phasar[3];
- X /* convert to seconds local time, so we can use localtime()
- X
- X--- 393,400 -----
- X (void)sprintf(tbuf, "Lunation %d ", lunation + 1);
- X prtxy(APOS(4), 49);
- X
- X! /* flush the pixwin updates to the screen */
- X! pw_batch_off (cpw);
- X
- X return;
- X }
- X***************
- X*** 326,340
- X ltm->tm_hour, ltm->tm_min, timezone(tzp.tz_minuteswest, ltm->tm_isdst), ltm->tm_mday, monthnames[ltm->tm_mon], ltm->tm_year+1900);
- X prt(APOS(2));
- X
- X! lptime = phasar[3];
- X! /* convert to seconds local time, so we can use localtime()
- X! to handle dst calculations */
- X! clock = (long)((lptime - J1970) * 24. * 3600.);
- X! ltm = localtime(&clock);
- X! sprintf(tbuf,
- X! "Last quarter: %02d:%02d %s %2d %s %d ",
- X! ltm->tm_hour, ltm->tm_min, timezone(tzp.tz_minuteswest, ltm->tm_isdst), ltm->tm_mday, monthnames[ltm->tm_mon], ltm->tm_year+1900);
- X! prt(APOS(3));
- X
- X lptime = phasar[4];
- X /* convert to seconds local time, so we can use localtime()
- X
- X--- 396,404 -----
- X /* flush the pixwin updates to the screen */
- X pw_batch_off (cpw);
- X
- X! return;
- X! }
- X! #undef APOS
- X
- X
- X /*
- X***************
- X*** 336,342
- X ltm->tm_hour, ltm->tm_min, timezone(tzp.tz_minuteswest, ltm->tm_isdst), ltm->tm_mday, monthnames[ltm->tm_mon], ltm->tm_year+1900);
- X prt(APOS(3));
- X
- X! lptime = phasar[4];
- X /* convert to seconds local time, so we can use localtime()
- X to handle dst calculations */
- X clock = (long)rint((lptime - J1970) * 24. * 3600.);
- X
- X--- 400,418 -----
- X }
- X #undef APOS
- X
- X!
- X! /*
- X! * FMT_PHASE_TIME -- Format the provided julian date into the provided buffer
- X! * in local time format for screen display
- X! */
- X!
- X! fmt_phase_time (utime, buf)
- X! double utime;
- X! char *buf;
- X! {
- X! long clock;
- X! struct tm *ltm, *localtime();
- X!
- X /* convert to seconds local time, so we can use localtime()
- X to handle dst calculations */
- X clock = (long)((utime - J1970) * 24. * 3600.);
- X***************
- X*** 339,345
- X lptime = phasar[4];
- X /* convert to seconds local time, so we can use localtime()
- X to handle dst calculations */
- X! clock = (long)rint((lptime - J1970) * 24. * 3600.);
- X ltm = localtime(&clock);
- X sprintf(tbuf,
- X "Next new moon: %02d:%02d %s %2d %s %d ",
- X
- X--- 415,421 -----
- X
- X /* convert to seconds local time, so we can use localtime()
- X to handle dst calculations */
- X! clock = (long)((utime - J1970) * 24. * 3600.);
- X ltm = localtime(&clock);
- X (void)sprintf (buf, " %02d:%02d %s %2d %s %d ",
- X ltm->tm_hour, ltm->tm_min, timezone(tzp.tz_minuteswest, ltm->tm_isdst), ltm->tm_mday, monthnames[ltm->tm_mon], ltm->tm_year+1900);
- X***************
- X*** 341,353
- X to handle dst calculations */
- X clock = (long)rint((lptime - J1970) * 24. * 3600.);
- X ltm = localtime(&clock);
- X! sprintf(tbuf,
- X! "Next new moon: %02d:%02d %s %2d %s %d ",
- X! ltm->tm_hour, ltm->tm_min, timezone(tzp.tz_minuteswest, ltm->tm_isdst), ltm->tm_mday, monthnames[ltm->tm_mon], ltm->tm_year+1900);
- X! prt(APOS(4));
- X! sprintf(tbuf, "Lunation %d ", lunation + 1);
- X! prtxy(APOS(4), 52);
- X! #undef APOS
- X }
- X
- X /* JDATE -- Convert internal GMT date and time to Julian day
- X
- X--- 417,424 -----
- X to handle dst calculations */
- X clock = (long)((utime - J1970) * 24. * 3600.);
- X ltm = localtime(&clock);
- X! (void)sprintf (buf, " %02d:%02d %s %2d %s %d ",
- X! ltm->tm_hour, ltm->tm_min, timezone(tzp.tz_minuteswest, ltm->tm_isdst), ltm->tm_mday, monthnames[ltm->tm_mon], ltm->tm_year+1900);
- X }
- X
- X
- X***************
- X*** 350,357
- X #undef APOS
- X }
- X
- X- /* JDATE -- Convert internal GMT date and time to Julian day
- X- and fraction. */
- X
- X static long jdate(t)
- X struct tm *t;
- X
- X--- 421,426 -----
- X ltm->tm_hour, ltm->tm_min, timezone(tzp.tz_minuteswest, ltm->tm_isdst), ltm->tm_mday, monthnames[ltm->tm_mon], ltm->tm_year+1900);
- X }
- X
- X
- X /*
- X * PAINT_LABELS -- Draw the labels into the canvas (open) window and right
- X***************
- X*** 353,360
- X /* JDATE -- Convert internal GMT date and time to Julian day
- X and fraction. */
- X
- X! static long jdate(t)
- X! struct tm *t;
- X {
- X long c, m, y;
- X
- X
- X--- 422,435 -----
- X }
- X
- X
- X! /*
- X! * PAINT_LABELS -- Draw the labels into the canvas (open) window and right
- X! * justify them. Done once at startup. We paint the labels
- X! * separately to minimize the amount of screen real-estate
- X! * being modified on each update.
- X! */
- X!
- X! paint_labels ()
- X {
- X int i;
- X
- X***************
- X*** 356,362
- X static long jdate(t)
- X struct tm *t;
- X {
- X! long c, m, y;
- X
- X y = t->tm_year + 1900;
- X m = t->tm_mon + 1;
- X
- X--- 431,437 -----
- X
- X paint_labels ()
- X {
- X! int i;
- X
- X for (i = 0; i < 4; i++) {
- X pw_text (cpw, charwid * (17 - strlen (labels [i])),
- X***************
- X*** 358,363
- X {
- X long c, m, y;
- X
- X y = t->tm_year + 1900;
- X m = t->tm_mon + 1;
- X if (m > 2)
- X
- X--- 433,463 -----
- X {
- X int i;
- X
- X+ for (i = 0; i < 4; i++) {
- X+ pw_text (cpw, charwid * (17 - strlen (labels [i])),
- X+ charhgt * (i + 1), PIX_SRC,
- X+ font, labels[i]);
- X+ }
- X+ for (i = 4; i < 9; i++) {
- X+ pw_text (cpw, charwid * (17 - strlen (labels [i])),
- X+ charhgt * (i + 7), PIX_SRC,
- X+ font, labels[i]);
- X+ }
- X+ }
- X+
- X+
- X+ /*
- X+ * JDATE -- Convert internal GMT date and time to Julian day
- X+ * and fraction.
- X+ */
- X+
- X+ static
- X+ long
- X+ jdate (t)
- X+ struct tm *t;
- X+ {
- X+ long c, m, y;
- X+
- X y = t->tm_year + 1900;
- X m = t->tm_mon + 1;
- X if (m > 2) {
- X***************
- X*** 360,370
- X
- X y = t->tm_year + 1900;
- X m = t->tm_mon + 1;
- X! if (m > 2)
- X! m = m - 3;
- X! else {
- X! m = m + 9;
- X! y--;
- X }
- X c = y / 100L; /* Compute century */
- X y -= 100L * c;
- X
- X--- 460,470 -----
- X
- X y = t->tm_year + 1900;
- X m = t->tm_mon + 1;
- X! if (m > 2) {
- X! m = m - 3;
- X! } else {
- X! m = m + 9;
- X! y--;
- X }
- X c = y / 100L; /* Compute century */
- X y -= 100L * c;
- X***************
- X*** 368,375
- X }
- X c = y / 100L; /* Compute century */
- X y -= 100L * c;
- X! return t->tm_mday + (c * 146097L) / 4 + (y * 1461L) / 4 +
- X! (m * 153L + 2) / 5 + 1721119L;
- X }
- X
- X /* JTIME -- Convert internal GMT date and time to astronomical Julian
- X
- X--- 468,475 -----
- X }
- X c = y / 100L; /* Compute century */
- X y -= 100L * c;
- X! return (t->tm_mday + (c * 146097L) / 4 + (y * 1461L) / 4 +
- X! (m * 153L + 2) / 5 + 1721119L);
- X }
- X
- X
- X***************
- X*** 372,380
- X (m * 153L + 2) / 5 + 1721119L;
- X }
- X
- X- /* JTIME -- Convert internal GMT date and time to astronomical Julian
- X- time (i.e. Julian date plus day fraction, expressed as
- X- a double). */
- X
- X static double jtime(t)
- X struct tm *t;
- X
- X--- 472,477 -----
- X (m * 153L + 2) / 5 + 1721119L);
- X }
- X
- X
- X /*
- X * JTIME -- Convert internal GMT date and time to astronomical Julian
- X***************
- X*** 376,383
- X time (i.e. Julian date plus day fraction, expressed as
- X a double). */
- X
- X! static double jtime(t)
- X! struct tm *t;
- X {
- X return (jdate(t) - 0.5) +
- X (t->tm_sec + 60 * (t->tm_min + 60 * t->tm_hour)) / 86400.0;
- X
- X--- 473,488 -----
- X }
- X
- X
- X! /*
- X! * JTIME -- Convert internal GMT date and time to astronomical Julian
- X! * time (i.e. Julian date plus day fraction, expressed as
- X! * a double).
- X! */
- X!
- X! static
- X! double
- X! jtime (t)
- X! struct tm *t;
- X {
- X return (jdate (t) - 0.5) +
- X (t->tm_sec + 60 * (t->tm_min + 60 * t->tm_hour)) / 86400.0;
- X***************
- X*** 379,385
- X static double jtime(t)
- X struct tm *t;
- X {
- X! return (jdate(t) - 0.5) +
- X (t->tm_sec + 60 * (t->tm_min + 60 * t->tm_hour)) / 86400.0;
- X }
- X
- X
- X--- 484,490 -----
- X jtime (t)
- X struct tm *t;
- X {
- X! return (jdate (t) - 0.5) +
- X (t->tm_sec + 60 * (t->tm_min + 60 * t->tm_hour)) / 86400.0;
- X }
- X
- X***************
- X*** 383,390
- X (t->tm_sec + 60 * (t->tm_min + 60 * t->tm_hour)) / 86400.0;
- X }
- X
- X- /* JYEAR -- Convert Julian date to year, month, day, which are
- X- returned via integer pointers to integers. */
- X
- X static void jyear(td, yy, mm, dd)
- X double td;
- X
- X--- 488,493 -----
- X (t->tm_sec + 60 * (t->tm_min + 60 * t->tm_hour)) / 86400.0;
- X }
- X
- X
- X /*
- X * JYEAR -- Convert Julian date to year, month, day, which are
- X***************
- X*** 386,394
- X /* JYEAR -- Convert Julian date to year, month, day, which are
- X returned via integer pointers to integers. */
- X
- X! static void jyear(td, yy, mm, dd)
- X! double td;
- X! int *yy, *mm, *dd;
- X {
- X double j, d, y, m;
- X
- X
- X--- 489,504 -----
- X }
- X
- X
- X! /*
- X! * JYEAR -- Convert Julian date to year, month, day, which are
- X! * returned via integer pointers to integers.
- X! */
- X!
- X! static
- X! void
- X! jyear (td, yy, mm, dd)
- X! double td;
- X! int *yy, *mm, *dd;
- X {
- X double j, d, y, m;
- X
- X***************
- X*** 392,398
- X {
- X double j, d, y, m;
- X
- X! td += 0.5; /* Astronomical to civil */
- X j = floor(td);
- X j = j - 1721119.0;
- X y = floor(((4 * j) - 1) / 146097.0);
- X
- X--- 502,508 -----
- X {
- X double j, d, y, m;
- X
- X! td += 0.5; /* Astronomical to civil */
- X j = floor(td);
- X j = j - 1721119.0;
- X y = floor(((4 * j) - 1) / 146097.0);
- X***************
- X*** 406,412
- X d = floor((d + 5.0) / 5.0);
- X y = (100.0 * y) + j;
- X if (m < 10.0)
- X! m = m + 3;
- X else {
- X m = m - 9;
- X y = y + 1;
- X
- X--- 516,522 -----
- X d = floor((d + 5.0) / 5.0);
- X y = (100.0 * y) + j;
- X if (m < 10.0)
- X! m = m + 3;
- X else {
- X m = m - 9;
- X y = y + 1;
- X***************
- X*** 408,415
- X if (m < 10.0)
- X m = m + 3;
- X else {
- X! m = m - 9;
- X! y = y + 1;
- X }
- X *yy = y;
- X *mm = m;
- X
- X--- 518,525 -----
- X if (m < 10.0)
- X m = m + 3;
- X else {
- X! m = m - 9;
- X! y = y + 1;
- X }
- X *yy = y;
- X *mm = m;
- X***************
- X*** 416,422
- X *dd = d;
- X }
- X
- X- /* JHMS -- Convert Julian time to hour, minutes, and seconds. */
- X
- X static void jhms(j, h, m, s)
- X double j;
- X
- X--- 526,531 -----
- X *dd = d;
- X }
- X
- X
- X /*
- X * JHMS -- Convert Julian time to hour, minutes, and seconds.
- X***************
- X*** 418,426
- X
- X /* JHMS -- Convert Julian time to hour, minutes, and seconds. */
- X
- X! static void jhms(j, h, m, s)
- X! double j;
- X! int *h, *m, *s;
- X {
- X long ij;
- X
- X
- X--- 527,541 -----
- X }
- X
- X
- X! /*
- X! * JHMS -- Convert Julian time to hour, minutes, and seconds.
- X! */
- X!
- X! static
- X! void
- X! jhms(j, h, m, s)
- X! double j;
- X! int *h, *m, *s;
- X {
- X long ij;
- X
- X***************
- X*** 424,430
- X {
- X long ij;
- X
- X! j += 0.5; /* Astronomical to civil */
- X ij = (j - floor(j)) * 86400.0;
- X *h = ij / 3600L;
- X *m = (ij / 60L) % 60L;
- X
- X--- 539,545 -----
- X {
- X long ij;
- X
- X! j += 0.5; /* Astronomical to civil */
- X ij = (j - floor(j)) * 86400.0;
- X *h = ij / 3600L;
- X *m = (ij / 60L) % 60L;
- X***************
- X*** 431,447
- X *s = ij % 60L;
- X }
- X
- X- /* MEANPHASE -- Calculates mean phase of the Moon for a given
- X- base date and desired phase:
- X- 0.0 New Moon
- X- 0.25 First quarter
- X- 0.5 Full moon
- X- 0.75 Last quarter
- X- Beware!!! This routine returns meaningless
- X- results for any other phase arguments. Don't
- X- attempt to generalise it without understanding
- X- that the motion of the moon is far more complicated
- X- that this calculation reveals. */
- X
- X static double meanphase(sdate, phase, usek)
- X double sdate, phase;
- X
- X--- 546,551 -----
- X *s = ij % 60L;
- X }
- X
- X
- X /*
- X * MEANPHASE -- Calculates mean phase of the Moon for a given
- X***************
- X*** 443,451
- X that the motion of the moon is far more complicated
- X that this calculation reveals. */
- X
- X! static double meanphase(sdate, phase, usek)
- X! double sdate, phase;
- X! double *usek;
- X {
- X int yy, mm, dd;
- X double k, t, t2, t3, nt1;
- X
- X--- 547,567 -----
- X }
- X
- X
- X! /*
- X! * MEANPHASE -- Calculates mean phase of the Moon for a given
- X! * base date. This argument K to this function is
- X! * the precomputed synodic month index, given by:
- X! *
- X! * K = (year - 1900) * 12.3685
- X! *
- X! * where year is expressed as a year and fractional
- X! * year.
- X! */
- X!
- X! static
- X! double
- X! meanphase (sdate, k)
- X! double sdate, k;
- X {
- X double t, t2, t3, nt1;
- X
- X***************
- X*** 447,454
- X double sdate, phase;
- X double *usek;
- X {
- X! int yy, mm, dd;
- X! double k, t, t2, t3, nt1;
- X
- X jyear(sdate, &yy, &mm, &dd);
- X
- X
- X--- 563,569 -----
- X meanphase (sdate, k)
- X double sdate, k;
- X {
- X! double t, t2, t3, nt1;
- X
- X /* Time in Julian centuries from 1900 January 0.5 */
- X t = (sdate - 2415020.0) / 36525;
- X***************
- X*** 450,459
- X int yy, mm, dd;
- X double k, t, t2, t3, nt1;
- X
- X- jyear(sdate, &yy, &mm, &dd);
- X-
- X- k = (yy + ((mm - 1) * (1.0 / 12.0)) - 1900) * 12.3685;
- X-
- X /* Time in Julian centuries from 1900 January 0.5 */
- X t = (sdate - 2415020.0) / 36525;
- X t2 = t * t; /* Square for frequent use */
- X
- X--- 565,570 -----
- X {
- X double t, t2, t3, nt1;
- X
- X /* Time in Julian centuries from 1900 January 0.5 */
- X t = (sdate - 2415020.0) / 36525;
- X t2 = t * t; /* Square for frequent use */
- X***************
- X*** 459,465
- X t2 = t * t; /* Square for frequent use */
- X t3 = t2 * t; /* Cube for frequent use */
- X
- X- *usek = k = floor(k) + phase;
- X nt1 = 2415020.75933 + synmonth * k
- X + 0.0001178 * t2
- X - 0.000000155 * t3
- X
- X--- 570,575 -----
- X t2 = t * t; /* Square for frequent use */
- X t3 = t2 * t; /* Cube for frequent use */
- X
- X nt1 = 2415020.75933 + synmonth * k
- X + 0.0001178 * t2
- X - 0.000000155 * t3
- X***************
- X*** 461,469
- X
- X *usek = k = floor(k) + phase;
- X nt1 = 2415020.75933 + synmonth * k
- X! + 0.0001178 * t2
- X! - 0.000000155 * t3
- X! + 0.00033 * dsin(166.56 + 132.87 * t - 0.009173 * t2);
- X
- X return nt1;
- X }
- X
- X--- 571,579 -----
- X t3 = t2 * t; /* Cube for frequent use */
- X
- X nt1 = 2415020.75933 + synmonth * k
- X! + 0.0001178 * t2
- X! - 0.000000155 * t3
- X! + 0.00033 * dsin(166.56 + 132.87 * t - 0.009173 * t2);
- X
- X return nt1;
- X }
- X***************
- X*** 468,477
- X return nt1;
- X }
- X
- X- /* TRUEPHASE -- Given a K value used to determine the
- X- mean phase of the new moon, and a phase
- X- selector (0.0, 0.25, 0.5, 0.75), obtain
- X- the true, corrected phase time. */
- X
- X static double truephase(k, phase)
- X double k, phase;
- X
- X--- 578,583 -----
- X return nt1;
- X }
- X
- X
- X /*
- X * TRUEPHASE -- Given a K value used to determine the
- X***************
- X*** 473,480
- X selector (0.0, 0.25, 0.5, 0.75), obtain
- X the true, corrected phase time. */
- X
- X! static double truephase(k, phase)
- X! double k, phase;
- X {
- X double t, t2, t3, pt, m, mprime, f;
- X int apcor = FALSE;
- X
- X--- 579,595 -----
- X }
- X
- X
- X! /*
- X! * TRUEPHASE -- Given a K value used to determine the
- X! * mean phase of the new moon, and a phase
- X! * selector (0.0, 0.25, 0.5, 0.75), obtain
- X! * the true, corrected phase time.
- X! */
- X!
- X! static
- X! double
- X! truephase(k, phase)
- X! double k, phase;
- X {
- X double t, t2, t3, pt, m, mprime, f;
- X int apcor = FALSE;
- X***************
- X*** 545,551
- X apcor = TRUE;
- X }
- X if (!apcor) {
- X! fprintf(stderr, "TRUEPHASE called with invalid phase selector.\n");
- X abort();
- X }
- X return pt;
- X
- X--- 660,667 -----
- X apcor = TRUE;
- X }
- X if (!apcor) {
- X! (void)fprintf (stderr,
- X! "TRUEPHASE called with invalid phase selector.\n");
- X abort();
- X }
- X return pt;
- X***************
- X*** 551,560
- X return pt;
- X }
- X
- X- /* PHASEHUNT -- Find time of phases of the moon which surround
- X- the current date. Five phases are found, starting
- X- and ending with the new moons which bound the
- X- current lunation. */
- X
- X static void phasehunt(sdate, phases)
- X double sdate;
- X
- X--- 667,672 -----
- X return pt;
- X }
- X
- X
- X /*
- X * PHASEHUNT -- Find time of phases of the moon which surround
- X***************
- X*** 556,564
- X and ending with the new moons which bound the
- X current lunation. */
- X
- X! static void phasehunt(sdate, phases)
- X! double sdate;
- X! double phases[5];
- X {
- X double adate, k1, k2, nt1, nt2;
- X
- X
- X--- 668,685 -----
- X }
- X
- X
- X! /*
- X! * PHASEHUNT -- Find time of phases of the moon which surround
- X! * the current date. Five phases are found, starting
- X! * and ending with the new moons which bound the
- X! * current lunation.
- X! */
- X!
- X! static
- X! void
- X! phasehunt (sdate, phases)
- X! double sdate;
- X! double phases [5];
- X {
- X int yy, mm, dd;
- X double adate, k1, k2, nt1, nt2;
- X***************
- X*** 560,566
- X double sdate;
- X double phases[5];
- X {
- X! double adate, k1, k2, nt1, nt2;
- X
- X adate = sdate - 45;
- X nt1 = meanphase(adate, 0.0, &k1);
- X
- X--- 681,688 -----
- X double sdate;
- X double phases [5];
- X {
- X! int yy, mm, dd;
- X! double adate, k1, k2, nt1, nt2;
- X
- X adate = sdate - 45;
- X jyear(adate, &yy, &mm, &dd);
- X***************
- X*** 563,569
- X double adate, k1, k2, nt1, nt2;
- X
- X adate = sdate - 45;
- X! nt1 = meanphase(adate, 0.0, &k1);
- X while (TRUE) {
- X adate += synmonth;
- X nt2 = meanphase(adate, 0.0, &k2);
- X
- X--- 685,694 -----
- X double adate, k1, k2, nt1, nt2;
- X
- X adate = sdate - 45;
- X! jyear(adate, &yy, &mm, &dd);
- X! k1 = floor((yy + ((mm - 1) * (1.0 / 12.0)) - 1900) * 12.3685);
- X!
- X! adate = nt1 = meanphase(adate, k1);
- X while (TRUE) {
- X adate += synmonth;
- X k2 = k1 + 1;
- X***************
- X*** 565,576
- X adate = sdate - 45;
- X nt1 = meanphase(adate, 0.0, &k1);
- X while (TRUE) {
- X! adate += synmonth;
- X! nt2 = meanphase(adate, 0.0, &k2);
- X! if (nt1 <= sdate && nt2 > sdate)
- X! break;
- X! nt1 = nt2;
- X! k1 = k2;
- X }
- X phases[0] = truephase(k1, 0.0);
- X phases[1] = truephase(k1, 0.25);
- X
- X--- 690,702 -----
- X
- X adate = nt1 = meanphase(adate, k1);
- X while (TRUE) {
- X! adate += synmonth;
- X! k2 = k1 + 1;
- X! nt2 = meanphase(adate, k2);
- X! if (nt1 <= sdate && nt2 > sdate)
- X! break;
- X! nt1 = nt2;
- X! k1 = k2;
- X }
- X phases[0] = truephase(k1, 0.0);
- X phases[1] = truephase(k1, 0.25);
- X***************
- X*** 579,585
- X phases[4] = truephase(k2, 0.0);
- X }
- X
- X- /* KEPLER -- Solve the equation of Kepler. */
- X
- X static double kepler(m, ecc)
- X double m, ecc;
- X
- X--- 705,710 -----
- X phases[4] = truephase(k2, 0.0);
- X }
- X
- X
- X /*
- X * KEPLER -- Solve the equation of Kepler.
- X***************
- X*** 581,588
- X
- X /* KEPLER -- Solve the equation of Kepler. */
- X
- X! static double kepler(m, ecc)
- X! double m, ecc;
- X {
- X double e, delta;
- X #define EPSILON 1E-6
- X
- X--- 706,719 -----
- X }
- X
- X
- X! /*
- X! * KEPLER -- Solve the equation of Kepler.
- X! */
- X!
- X! static
- X! double
- X! kepler(m, ecc)
- X! double m, ecc;
- X {
- X double e, delta;
- X #define EPSILON 1E-6
- X***************
- X*** 589,597
- X
- X e = m = torad(m);
- X do {
- X! delta = e - ecc * sin(e) - m;
- X! e -= delta / (1 - ecc * cos(e));
- X! } while (abs(delta) > EPSILON);
- X return e;
- X }
- X
- X
- X--- 720,728 -----
- X
- X e = m = torad(m);
- X do {
- X! delta = e - ecc * sin(e) - m;
- X! e -= delta / (1 - ecc * cos(e));
- X! } while (abs (delta) > EPSILON);
- X return e;
- X }
- X
- X***************
- X*** 595,601
- X return e;
- X }
- X
- X- /* PHASE -- Calculate phase of moon as a fraction:
- X
- X The argument is the time for which the phase is requested,
- X expressed as a Julian date and fraction. Returns the terminator
- X
- X--- 726,731 -----
- X return e;
- X }
- X
- X
- X /*
- X * PHASE -- Calculate phase of moon as a fraction:
- X***************
- X*** 597,610
- X
- X /* PHASE -- Calculate phase of moon as a fraction:
- X
- X! The argument is the time for which the phase is requested,
- X! expressed as a Julian date and fraction. Returns the terminator
- X! phase angle as a percentage of a full circle (i.e., 0 to 1),
- X! and stores into pointer arguments the illuminated fraction of
- X! the Moon's disc, the Moon's age in days and fraction, the
- X! distance of the Moon from the centre of the Earth, and the
- X! angular diameter subtended by the Moon as seen by an observer
- X! at the centre of the Earth.
- X
- X */
- X
- X
- X--- 727,744 -----
- X }
- X
- X
- X! /*
- X! * PHASE -- Calculate phase of moon as a fraction:
- X! *
- X! * The argument is the time for which the phase is requested,
- X! * expressed as a Julian date and fraction. Returns the terminator
- X! * phase angle as a percentage of a full circle (i.e., 0 to 1),
- X! * and stores into pointer arguments the illuminated fraction of
- X! * the Moon's disc, the Moon's age in days and fraction, the
- X! * distance of the Moon from the centre of the Earth, and the
- X! * angular diameter subtended by the Moon as seen by an observer
- X! * at the centre of the Earth.
- X! */
- X
- X static
- X double
- X***************
- X*** 606,621
- X angular diameter subtended by the Moon as seen by an observer
- X at the centre of the Earth.
- X
- X! */
- X!
- X! static double phase(pdate, pphase, mage, dist, angdia, sudist, suangdia)
- X! double pdate;
- X! double *pphase; /* Illuminated fraction */
- X! double *mage; /* Age of moon in days */
- X! double *dist; /* Distance in kilometres */
- X! double *angdia; /* Angular diameter in degrees */
- X! double *sudist; /* Distance to Sun */
- X! double *suangdia; /* Sun's angular diameter */
- X {
- X
- X double Day, N, M, Ec, Lambdasun, ml, MM, MN, Ev, Ae, A3, MmP,
- X
- X--- 740,755 -----
- X * at the centre of the Earth.
- X */
- X
- X! static
- X! double
- X! phase (pdate, pphase, mage, dist, angdia, sudist, suangdia)
- X! double pdate;
- X! double *pphase; /* Illuminated fraction */
- X! double *mage; /* Age of moon in days */
- X! double *dist; /* Distance in kilometres */
- X! double *angdia; /* Angular diameter in degrees */
- X! double *sudist; /* Distance to Sun */
- X! double *suangdia; /* Sun's angular diameter */
- X {
- X
- X double Day, N, M, Ec, Lambdasun, ml, MM, MN, Ev, Ae, A3, MmP,
- X***************
- X*** 618,628
- X double *suangdia; /* Sun's angular diameter */
- X {
- X
- X! double Day, N, M, Ec, Lambdasun, ml, MM, MN, Ev, Ae, A3, MmP,
- X! mEc, A4, lP, V, lPP, NP, y, x, Lambdamoon, BetaM,
- X! MoonAge, MoonPhase,
- X! MoonDist, MoonDFrac, MoonAng, MoonPar,
- X! F, SunDist, SunAng;
- X
- X /* Calculation of the Sun's position */
- X
- X
- X--- 752,762 -----
- X double *suangdia; /* Sun's angular diameter */
- X {
- X
- X! double Day, N, M, Ec, Lambdasun, ml, MM, MN, Ev, Ae, A3, MmP,
- X! mEc, A4, lP, V, lPP, NP, y, x, Lambdamoon, BetaM,
- X! MoonAge, MoonPhase,
- X! MoonDist, MoonDFrac, MoonAng, MoonPar,
- X! F, SunDist, SunAng;
- X
- X /* Calculation of the Sun's position */
- X
- X***************
- X*** 626,636
- X
- X /* Calculation of the Sun's position */
- X
- X! Day = pdate - epoch; /* Date within epoch */
- X! N = fixangle((360 / 365.2422) * Day); /* Mean anomaly of the Sun */
- X! M = fixangle(N + elonge - elongp); /* Convert from perigee
- X! co-ordinates to epoch 1980.0 */
- X! Ec = kepler(M, eccent); /* Solve equation of Kepler */
- X Ec = sqrt((1 + eccent) / (1 - eccent)) * tan(Ec / 2);
- X Ec = 2 * todeg(atan(Ec)); /* True anomaly */
- X Lambdasun = fixangle(Ec + elongp); /* Sun's geocentric ecliptic
- X
- X--- 760,770 -----
- X
- X /* Calculation of the Sun's position */
- X
- X! Day = pdate - epoch; /* Date within epoch */
- X! N = fixangle((360 / 365.2422) * Day); /* Mean anomaly of the Sun */
- X! M = fixangle(N + elonge - elongp); /* Convert from perigee
- X! co-ordinates to epoch 1980.0 */
- X! Ec = kepler(M, eccent); /* Solve equation of Kepler */
- X Ec = sqrt((1 + eccent) / (1 - eccent)) * tan(Ec / 2);
- X Ec = 2 * todeg(atan(Ec)); /* True anomaly */
- X Lambdasun = fixangle(Ec + elongp); /* Sun's geocentric ecliptic
- X***************
- X*** 632,640
- X co-ordinates to epoch 1980.0 */
- X Ec = kepler(M, eccent); /* Solve equation of Kepler */
- X Ec = sqrt((1 + eccent) / (1 - eccent)) * tan(Ec / 2);
- X! Ec = 2 * todeg(atan(Ec)); /* True anomaly */
- X! Lambdasun = fixangle(Ec + elongp); /* Sun's geocentric ecliptic
- X! longitude */
- X /* Orbital distance factor */
- X F = ((1 + eccent * cos(torad(Ec))) / (1 - eccent * eccent));
- X SunDist = sunsmax / F; /* Distance to Sun in km */
- X
- X--- 766,774 -----
- X co-ordinates to epoch 1980.0 */
- X Ec = kepler(M, eccent); /* Solve equation of Kepler */
- X Ec = sqrt((1 + eccent) / (1 - eccent)) * tan(Ec / 2);
- X! Ec = 2 * todeg(atan(Ec)); /* True anomaly */
- X! Lambdasun = fixangle(Ec + elongp); /* Sun's geocentric ecliptic
- X! longitude */
- X /* Orbital distance factor */
- X F = ((1 + eccent * cos(torad(Ec))) / (1 - eccent * eccent));
- X SunDist = sunsmax / F; /* Distance to Sun in km */
- X***************
- X*** 637,644
- X longitude */
- X /* Orbital distance factor */
- X F = ((1 + eccent * cos(torad(Ec))) / (1 - eccent * eccent));
- X! SunDist = sunsmax / F; /* Distance to Sun in km */
- X! SunAng = F * sunangsiz; /* Sun's angular size in degrees */
- X
- X
- X /* Calculation of the Moon's position */
- X
- X--- 771,778 -----
- X longitude */
- X /* Orbital distance factor */
- X F = ((1 + eccent * cos(torad(Ec))) / (1 - eccent * eccent));
- X! SunDist = sunsmax / F; /* Distance to Sun in km */
- X! SunAng = F * sunangsiz; /* Sun's angular size in degrees */
- X
- X
- X /* Calculation of the Moon's position */
- X***************
- X*** 725,728
- X *suangdia = SunAng;
- X return fixangle(MoonAge) / 360.0;
- X }
- X! #endif /* NO_SUN_MOON */
- X
- X--- 859,862 -----
- X *suangdia = SunAng;
- X return fixangle(MoonAge) / 360.0;
- X }
- X! #endif /* NO_SUN_MOON */
- END_OF_FILE
- if test 52733 -ne `wc -c <'patches04b'`; then
- echo shar: \"'patches04b'\" unpacked with wrong size!
- fi
- # end of 'patches04b'
- fi
- echo shar: End of archive 2 \(of 4\).
- cp /dev/null ark2isdone
- MISSING=""
- for I in 1 2 3 4 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 4 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
-